package com.zx.map.dao.mapper;


import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.annotations.Param;

import com.zx.map.dao.model.ActiveRedpacket;
import com.zx.map.dao.model.Redpacket;
import com.zx.map.dao.model.RedpacketExample;


public interface RedpacketMapper {
    long countByExample(RedpacketExample example);

    int deleteByExample(RedpacketExample example);

    int deleteByPrimaryKey(Integer redpacketId);

    int insert(Redpacket record);

    int insertSelective(Redpacket record);

    List<Redpacket> selectByExample(RedpacketExample example);

    Redpacket selectByPrimaryKey(Integer redpacketId);

    int updateByExampleSelective(@Param("record") Redpacket record, @Param("example") RedpacketExample example);

    int updateByExample(@Param("record") Redpacket record, @Param("example") RedpacketExample example);

    int updateByPrimaryKeySelective(Redpacket record);

    int updateByPrimaryKey(Redpacket record);
    //删除红包活动
    void setDelStatu(int redpacketId);
    //分页查询红包活动信息
    List<Redpacket> getPageByModel(@Param("pageSize") int pageSize, @Param("pageBegin") int pageNum, @Param("example") RedpacketExample example);
    //获取该商户的红包活动的个数
    int hasActiveRedpacket(String merchantId);
    //查询该商户的有效红包活动
    Redpacket queryRedpacketByMerchant(@Param("merchantId")String merchantId, @Param("needMoney") BigDecimal needMoney);
    //增加红包的领取数量
    int increaseJoinNum(@Param("redpacketId") Integer redpacketId);
    //修改红包的使用状态
    int dealRedpacketUsed(@Param("id")Integer id, @Param("consumeMoney")BigDecimal consumeMoney);
    //查询该红包的老会员的数量
    int countOldVipNum(@Param("redpacketId") Integer redpacketId);
    //选择使用的红包
    ActiveRedpacket selectUseRedpacket(@Param("merchantId")String merchantId, @Param("userId")String userId, @Param("consumeMoney")BigDecimal consumeMoney);
    /**
     * 获取红包的总金额
     * @param example
     * @return
     */
    BigDecimal getTotalActiveMoney(@Param("example") RedpacketExample example);
    /**
     * 获取发送的红包数量
     * @param example
     * @return
     */
    long getRedpacketNums(@Param("example") RedpacketExample example);
}